package org.gc.contact;

import java.io.IOException;
import java.io.InputStream;
import java.util.List;
import java.util.Properties;

import junit.framework.TestCase;


import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.log4j.PropertyConfigurator;
import org.gc.contact.model.ContactInfo;
import org.gc.contact.util.CommonUtil;

public class AbstractTestCase extends TestCase {

	protected final Log logger = LogFactory.getLog(getClass());
	
	protected Properties props;
	
	public AbstractTestCase(String name) {
		super(name);
		readProperties();
	}

	protected void printContacts(List<ContactInfo> contacts) {
		for (int i = 0; i < contacts.size(); i++) {
			if (logger.isDebugEnabled()) {
				logger.debug(contacts.get(i).toString());
			}
		}
	}

	private void readProperties() {
		InputStream in = CommonUtil.class
				.getResourceAsStream("/mail.properties");
		props = new Properties();
		try {
			props.load(in);
			PropertyConfigurator.configure(props);
		} catch (IOException e) {
			logger.error("Load Mail Properties Error", e);
		}
	}
}
